package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.mapper.OrderMapper;
import com.itheima.health.mapper.UserMapper;
import com.itheima.health.pojo.Member;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.service.MemberService;
import com.itheima.health.service.OrderService;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.service.UserService;
import com.itheima.health.utils.date.DateUtils;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.Map;
import java.util.Set;

@Service(retries = 0,timeout = 10000)
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public UserVO findUserInfoByUsername(String username) {
        //   根据账号查询用户所有角色和权限关键字
        UserVO userVO  =    baseMapper.findUserByUsername(username);
        //  2 根据 uid  查询角色信息
        Set<RoleVO> roleVOSet = baseMapper.findrolesByUid(userVO.getId());
        //  3.  根据  roleId ==查询 权限信息
        for (RoleVO roleVO : roleVOSet) {
            Set<Permission> permissionSet = baseMapper.findPermssionsByRoleId(roleVO.getId());
            roleVO.setPermissionSet(permissionSet);
        }
        userVO.setRoles(roleVOSet);
        return userVO;
    }
}



